package com.ityls.task;

import com.ityls.entity.OrderInfo;
import com.ityls.service.IOrderInfoService;
import com.ityls.service.IWxPaymentService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.io.IOException;
import java.util.List;

@Component
@Slf4j
public class WxPaymentTask {

    @Autowired
    IOrderInfoService iOrderInfoService;

    @Autowired
    IWxPaymentService iWxPaymentService;

    // @Scheduled(cron = "0/3 * * * * *")
    public void test() throws IOException {
        log.info("**********  开始查询超过订单 ********");
        List<OrderInfo> timeOutOrder = iOrderInfoService.getTimeOutOrder(1);
        for (OrderInfo orderInfo : timeOutOrder) {
            System.out.println(orderInfo);
            iWxPaymentService.checkOrderStatus(orderInfo.getOrderNo());
        }
    }

}
